package store.lunangangster.bpmn.model;

import java.util.ArrayList;
import java.util.List;

/**
 * Activity用于表示流程中的任务、工作行为。一个Activity可以表现为atomic和non-atomic (compound)的。
 * <p>包含在{@link Process}中的Activity有两种类型：
 * <ul>
 *   <li>{@link Task}</li>
 *   <li>{@link SubProcess}</li>
 * </ul>
 * 
 * @author cwk
 * @version 1.0
 */
public abstract class Activity extends FlowNode {
  // 当该属性为true时，则该Activity是作为补偿活动 (Compensation Activity)而出现
  // 补偿活动不包含在正常执行流中，其只有在其他补偿事件将其抛出时才可以执行
  // 补偿活动必须与补偿边界事件 (compensation boundary event)相关联
  // 该属性默认为false
  protected boolean isForCompensation;
  protected String defaultSequenceFlow;
  protected IOSpecification ioSpecification;
  protected ResourceRole resourceRole;
  protected List<DataAssociation> dataInputAssociations = new ArrayList<>();
  protected List<DataAssociation> dataOutputAssociations = new ArrayList<>();
  protected List<BoundaryEvent> boundaryEventList = new ArrayList<>();

  public boolean isForCompensation() {
    return isForCompensation;
  }

  public void setCompensation(boolean forCompensation) {
    isForCompensation = forCompensation;
  }

  public String getDefaultSequenceFlow() {
    return defaultSequenceFlow;
  }

  public void setDefaultSequenceFlow(String defaultSequenceFlow) {
    this.defaultSequenceFlow = defaultSequenceFlow;
  }

  public IOSpecification getIoSpecification() {
    return ioSpecification;
  }

  public void setIoSpecification(IOSpecification ioSpecification) {
    this.ioSpecification = ioSpecification;
  }

  public ResourceRole getResourceRole() {
    return resourceRole;
  }

  public void setResourceRole(ResourceRole resourceRole) {
    this.resourceRole = resourceRole;
  }

  public List<DataAssociation> getDataInputAssociations() {
    return dataInputAssociations;
  }

  public void addDataInputAssociations(
      DataAssociation dataAssociation) {
    this.dataInputAssociations.add(dataAssociation);
  }

  public List<DataAssociation> getDataOutputAssociations() {
    return dataOutputAssociations;
  }

  public void addDataOutputAssociations(
      DataAssociation dataAssociation) {
    this.dataOutputAssociations.add(dataAssociation);
  }

  public List<BoundaryEvent> getBoundaryEventList() {
    return boundaryEventList;
  }

  public void addBoundaryEvent(BoundaryEvent boundaryEvent) {
    this.boundaryEventList.add(boundaryEvent);
  }
}
